package com.example.demo.mapper;

import com.example.demo.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;

@Mapper
public interface UserMapper {
    @Select("select * from yue where id=#{id}")
    public User getUser(int id);

    @Select("select * from yue where name=#{name}")
    public List<User> getUserByName(String name);

    @Select("select * from yue limit #{limit} offset #{offset};")
    public List<User> getUserByPage1(int limit, int offset);

    @Select("select * from yue limit #{start},#{sizs}")
    public List<User> getUserByPage(int start,int size);

//增加用户
    @Insert("INSERT INTO yue (id,name, sex, age) VALUES (#{id},#{name}, #{sex}, #{age})")
    public int addUser(@Param("id") int id,
                       @Param("name") String name,
                       @Param("sex") String sex,
                       @Param("age") int age);

//删除用户
    @Delete("DELETE FROM yue WHERE id = #{id}")
    public int deleteUserById(int id);

//更新用户
    @Update("UPDATE yue SET name = #{name}, sex = #{sex}, age = #{age} WHERE id = #{id}")
    public int updateUser( int id,
                          String name,
                           String sex,
                           int age);
//查询用户
}
